package pers.cz.session;

/**
 * 全局上下文容器
 * @program: PostGirl-panent
 * @description: ContextHolder
 * @author: Cheng Zhi
 * @create: 2022-04-26 21:03
 **/
public final class ContextHolder {

    static ThreadLocal<RequestContext> requestContext = new ThreadLocal<RequestContext>();

    /**
     * 初始化容器,应该在请求来的时候的拦截器中初始化，
     */
    public static void initContext() {
        requestContext.set(new RequestContext());
    }

    /**
     * 获取请求范围的上下文
     * @return
     */
    public static RequestContext getRequestContext() {
        return requestContext.get();
    }
}
